package cn.maihe.elg.operation.repository.entity;

import cn.maihe.framework.starter.base.sql.BaseEntity;
import cn.maihe.framework.starter.base.sql.MapperInterface;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.baomidou.mybatisplus.enums.IdType;
import java.math.BigDecimal;
import java.util.Date;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@TableName("t_guarantee_info")
@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
@MapperInterface("cn.maihe.elg.operation.repository.mapper.GuaranteeInfoMapper")
public class GuaranteeInfoDO extends BaseEntity {
    /**
     * 主键
     */
    @TableId(type = IdType.ID_WORKER)
    private Long id;

    /**
     * 保函编号
     */
    @TableField(value = "guarantee_no")
    private String guaranteeNo;

    /**
     * 机构id
     */
    @TableField(value = "org_id")
    private Long orgId;

    /**
     * 交易中心订单号
     */
    @TableField(value = "center_order_id")
    private String centerOrderId;

    /**
     * 受理订单号
     */
    @TableField(value = "accept_order_no")
    private String acceptOrderNo;

    /**
     * 申请开函订单号
     */
    @TableField(value = "apply_order_no")
    private String applyOrderNo;

    /**
     * 保函服务起始时间
     */
    @TableField(value = "service_begin_time")
    private Date serviceBeginTime;

    /**
     * 保函服务终止时间
     */
    @TableField(value = "service_end_time")
    private Date serviceEndTime;

    /**
     * 投标保证金(分)
     */
    @TableField(value = "bid_bond")
    private Long bidBond;

    /**
     * 保费(分)
     */
    @TableField(value = "amount")
    private Long amount;

    /**
     * 收取保费费率
     */
    @TableField(value = "rate")
    private BigDecimal rate;

    /**
     * 支付类型：0-线下
     */
    @TableField(value = "pay_type")
    private String payType;

    /**
     * 支付账户
     */
    @TableField(value = "pay_account")
    private String payAccount;

    /**
     * 支付账户名称
     */
    @TableField(value = "pay_name")
    private String payName;

    /**
     * 支付者联系电话
     */
    @TableField(value = "pay_phone")
    private String payPhone;

    /**
     * 支付开户行名称
     */
    @TableField(value = "pay_bank_openbank")
    private String payBankOpenbank;

    /**
     * 保函责任？
     */
    @TableField(value = "guarantee_duty")
    private String guaranteeDuty;

    /**
     * 保函性质？
     */
    @TableField(value = "guarantee_property")
    private String guaranteeProperty;

    /**
     * 支付期限？
     */
    @TableField(value = "pay_limitation")
    private Integer payLimitation;

    /**
     * 银行支付流水号？
     */
    @TableField(value = "bank_record_no")
    private String bankRecordNo;

    /**
     * 适用的法律
     */
    @TableField(value = "applicable_law")
    private String applicableLaw;

    /**
     * 备注说明
     */
    @TableField(value = "remark")
    private String remark;

    /**
     * 创建时间
     */
    @TableField(value = "gmt_create", fill = FieldFill.INSERT)
    private Date gmtCreate;

    /**
     * 更新时间
     */
    @TableField(value = "gmt_modified", fill = FieldFill.INSERT_UPDATE)
    private Date gmtModified;

    /**
     * 创建用户
     */
    @TableField(value = "user_create", fill = FieldFill.INSERT)
    private String userCreate;

    /**
     * 更新用户
     */
    @TableField(value = "user_modified", fill = FieldFill.INSERT_UPDATE)
    private String userModified;

    /**
     * 索赔条款
     */
    @TableField(value = "claim_clause")
    private String claimClause;

    public GuaranteeInfoVo buildVo() {
        return new GuaranteeInfoVo(id, guaranteeNo, orgId, centerOrderId, acceptOrderNo, applyOrderNo, serviceBeginTime, serviceEndTime, bidBond, amount, rate, payType, payAccount, payName, payPhone, payBankOpenbank, guaranteeDuty, guaranteeProperty, payLimitation, bankRecordNo, applicableLaw, remark, gmtCreate, gmtModified, userCreate, userModified, claimClause);
    }

    public static GuaranteeInfoDO of(GuaranteeInfoVo vo) {
        return new GuaranteeInfoDO(vo.getId(), vo.getGuaranteeNo(), vo.getOrgId(), vo.getCenterOrderId(), vo.getAcceptOrderNo(), vo.getApplyOrderNo(), vo.getServiceBeginTime(), vo.getServiceEndTime(), vo.getBidBond(), vo.getAmount(), vo.getRate(), vo.getPayType(), vo.getPayAccount(), vo.getPayName(), vo.getPayPhone(), vo.getPayBankOpenbank(), vo.getGuaranteeDuty(), vo.getGuaranteeProperty(), vo.getPayLimitation(), vo.getBankRecordNo(), vo.getApplicableLaw(), vo.getRemark(), vo.getGmtCreate(), vo.getGmtModified(), vo.getUserCreate(), vo.getUserModified(), vo.getClaimClause());
    }
}
